// JavaScript Document
var pathName = window.document.location.pathname;
var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);

mydtree = new dTree('mydtree', projectName + "/static/js/externalcompany/images/", 'no', 'no');

var url = projectName + "/backend/hnt/extComOrgan/getOrganTree";

$.ajax({
	url : url,
	type : 'post',
	data : 'useable=1',
	async : false, //默认为true 异步   
	success : function(result) {
		var organList = eval(result);
		for (var i = 0; i < organList.length; i++) {
			var companyObj = organList[i];
			var id = companyObj.id;
			var pid = companyObj.pid;
			var name = companyObj.name;
			mydtree.add(id, pid, name, "javascript:setvalue('" + id + "','" + name + "');", name, "_self", false);
		}
		mydtree.add(0, -1, "根目录", "javascript:setvalue('" + 0 + "','" + "根目录" + "');", "根目录", "_self", false);
		mydtree.add(1, 0, "一级目录1", "javascript:setvalue('" + 1 + "','" + "一级目录1" + "');", "一级目录1", "_self", false);
		mydtree.add(2, 1, "二级目录1", "javascript:setvalue('" + 2 + "','" + "二级目录1" + "');", "二级目录1", "_self", false);
		mydtree.add(3, 0, "一级目录2", "javascript:setvalue('" + 3 + "','" + "一级目录2" + "');", "一级目录2", "_self", false);
		document.write(mydtree);
	},
	error : function() {
		alert('error');
	},
});